package com.ruoyi.business.controller;

import com.ruoyi.common.core.domain.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import springfox.documentation.annotations.ApiIgnore;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.business.domain.ViolationCategory;
import com.ruoyi.business.service.IViolationCategoryService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 违规类目Controller
 * 
 * @author lcz
 * @date 2025-01-19
 */
//@Api(tags = "违规类目相关接口")
@ApiIgnore
@RestController
@RequestMapping("/business/violationCategory")
public class ViolationCategoryController extends BaseController
{
    @Autowired
    private IViolationCategoryService violationCategoryService;

    /**
     * 查询违规类目列表
     */
    @ApiIgnore
    @PreAuthorize("@ss.hasPermi('business:violationCategory:list')")
    @GetMapping("/list")
    public TableDataInfo list(ViolationCategory violationCategory)
    {
        startPage();
        List<ViolationCategory> list = violationCategoryService.selectViolationCategoryList(violationCategory);
        return getDataTable(list);
    }

    /**
     * 导出违规类目列表
     */
    @ApiIgnore
    @PreAuthorize("@ss.hasPermi('business:violationCategory:export')")
    @Log(title = "违规类目", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ViolationCategory violationCategory)
    {
        List<ViolationCategory> list = violationCategoryService.selectViolationCategoryList(violationCategory);
        ExcelUtil<ViolationCategory> util = new ExcelUtil<ViolationCategory>(ViolationCategory.class);
        util.exportExcel(response, list, "违规类目数据");
    }

    /**
     * 获取违规类目详细信息
     */
    @ApiIgnore
    @PreAuthorize("@ss.hasPermi('business:violationCategory:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(violationCategoryService.selectViolationCategoryById(id));
    }

    /**
     * 新增违规类目
     */
    @ApiIgnore
    @PreAuthorize("@ss.hasPermi('business:violationCategory:add')")
    @Log(title = "违规类目", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ViolationCategory violationCategory)
    {
        return toAjax(violationCategoryService.insertViolationCategory(violationCategory));
    }

    /**
     * 修改违规类目
     */
    @ApiIgnore
    @PreAuthorize("@ss.hasPermi('business:violationCategory:edit')")
    @Log(title = "违规类目", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ViolationCategory violationCategory)
    {
        return toAjax(violationCategoryService.updateViolationCategory(violationCategory));
    }

    /**
     * 删除违规类目
     */
    @ApiIgnore
    @PreAuthorize("@ss.hasPermi('business:violationCategory:remove')")
    @Log(title = "违规类目", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(violationCategoryService.deleteViolationCategoryByIds(ids));
    }

    /** 前端接口 ***************************************************************************************************/
    /** 前端接口 ***************************************************************************************************/
    /** 前端接口 ***************************************************************************************************/

    /**
     * 查询违规类目列表
     * 接口路径：/violationCategory/front/list
     */
    @GetMapping("/front/list")
    @ApiOperation("前台查询违规类目列表")
    public TableDataInfo frontList(ViolationCategory violationCategory)
    {
        startPage();
        List<ViolationCategory> list = violationCategoryService.selectViolationCategoryList(violationCategory);
        return getDataTable(list);
    }

    /**
     * 获取违规类目详细信息
     * 接口路径：/violationCategory/front/info
     */
    @ApiOperation("前台获取违规类目详细信息")
    @GetMapping(value = "/front/info")
    public R<ViolationCategory> frontInfo(@RequestParam("id") Long id)
    {
        return R.ok(violationCategoryService.selectViolationCategoryById(id));
    }

    /**
     * 新增违规类目
     * 接口路径：/violationCategory/front/add
     */
    @ApiOperation("前台新增违规类目")
    @PostMapping("/front/add")
    public AjaxResult frontAdd(@RequestBody ViolationCategory violationCategory)
    {
        return toAjax(violationCategoryService.insertViolationCategory(violationCategory));
    }

    /**
     * 修改违规类目
     * 接口路径：/violationCategory/front/edit
     */
    @ApiOperation("前台修改违规类目")
    @PostMapping("/front/edit")
    public AjaxResult frontEdit(@RequestBody ViolationCategory violationCategory)
    {
        return toAjax(violationCategoryService.updateViolationCategory(violationCategory));
    }

    /**
     * 删除违规类目
     * 接口路径：/violationCategory/front/delete
     */
    @ApiOperation("前台删除违规类目")
    @GetMapping("/front/delete")
    public AjaxResult frontRemove(@RequestParam Long[] ids)
    {
        return toAjax(violationCategoryService.deleteViolationCategoryByIds(ids));
    }
}
